﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
					xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
					xmlns:local="clr-namespace:Microsoft.Research.DynamicDataDisplay.Charts"
					>

	<!--NewLegend-->
	<Style TargetType="{x:Type local:NewLegend}" BasedOn="{StaticResource {x:Type ItemsControl}}">
		<!--<Setter Property="Canvas.Top" Value="10"/>
		<Setter Property="Canvas.Right" Value="10"/>-->
		<Setter Property="Margin" Value="10,10,10,10"/>
		<Setter Property="HorizontalAlignment" Value="Left"/>
		<Setter Property="VerticalAlignment" Value="Top"/>
		<Setter Property="Panel.ZIndex" Value="10"/>
		<Setter Property="Background" Value="White"/>
		<Setter Property="BorderBrush" Value="DarkGray"/>
		<!--<Setter Property="ItemTemplate">
			<Setter.Value>
				<DataTemplate>
					<StackPanel Orientation="Horizontal">
						<CheckBox></CheckBox>
						<ContentControl Margin="10" Content="{Binding}"/>
					</StackPanel>
				</DataTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="ItemContainerStyle">
			<Setter.Value>
				<Style>
					<Setter Property="Control.Template">
						<Setter.Value>
							<ControlTemplate>
								<StackPanel Orientation="Horizontal">
									<CheckBox></CheckBox>
									<ContentControl Margin="10" Background="Orange" Content="{Binding}"/>
									<ContentPresenter Content="{Binding}"/>
								</StackPanel>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
			</Setter.Value>
		</Setter>-->
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:NewLegend}">
					<Grid>
						<Rectangle Name="backRect" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}"
								   RadiusX="10"
								   RadiusY="10"
								   StrokeThickness="1"/>
						<ScrollViewer CanContentScroll="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled"
									  Margin="5">
							<ItemsPresenter/>
						</ScrollViewer>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
	<local:LegendTopButtonToIsEnabledConverter x:Key="legendTopButtonConverter"/>
	<local:LegendBottomButtonIsEnabledConverter x:Key="legendBottomButtonConverter"/>

	<!--NewLegend No scroll style-->
	<Style TargetType="{x:Type local:NewLegend}" BasedOn="{StaticResource {x:Type local:NewLegend}}" x:Key="NoScrollLegendStyle">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:NewLegend}">
					<Grid>
						<Rectangle Name="backRect" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}"
								   RadiusX="10"
								   RadiusY="10"
								   StrokeThickness="1"/>
						<Grid>
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="*"/>
								<RowDefinition Height="Auto"/>
							</Grid.RowDefinitions>
	
							<RepeatButton Content="^" Grid.Row="0" Command="{x:Static ScrollBar.LineUpCommand}" CommandTarget="{Binding ElementName=scroll}"
										  Height="18" VerticalContentAlignment="Center" Padding="0"
										  IsEnabled="{Binding VerticalOffset, ElementName=scroll, Converter={StaticResource legendTopButtonConverter}}"/>
							
							<ScrollViewer Name="scroll"  Grid.Row="1"
										  CanContentScroll="True" VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Disabled"
										  Margin="5">
								<ItemsPresenter/>
							</ScrollViewer>
							<RepeatButton Content="v" Grid.Row="2" Command="{x:Static ScrollBar.LineDownCommand}" CommandTarget="{Binding ElementName=scroll}"
										  Height="18" VerticalContentAlignment="Center" Padding="0">
								<RepeatButton.IsEnabled>
									<MultiBinding Converter="{StaticResource legendBottomButtonConverter}">
										<Binding Path="ExtentHeight" ElementName="scroll"/>
										<Binding Path="ViewportHeight" ElementName="scroll"/>
										<Binding Path="VerticalOffset" ElementName="scroll"/>
									</MultiBinding>
								</RepeatButton.IsEnabled>
							</RepeatButton>
						</Grid>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<!--NewLegendItem-->
	<Style TargetType="{x:Type local:NewLegendItem}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:NewLegendItem}">
					<StackPanel Orientation="Horizontal">
						<StackPanel.ToolTip>
							<Binding Path="(local:NewLegend.DetailedDescription)"/>
						</StackPanel.ToolTip>
							
						<ContentControl Content="{TemplateBinding local:NewLegend.VisualContent}" Margin="2" VerticalAlignment="Center" />
						<ContentControl Margin="2" VerticalAlignment="Center">
							<ContentControl.Content>
								<Binding Path="(local:NewLegend.Description)"/>
							</ContentControl.Content>
						</ContentControl>
					</StackPanel>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>